package com.lepu.app.fun.tool.bmi;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.core.lib.application.BaseFragmentActivity;
import com.core.lib.utils.main.UtilityBase;
import com.eyzhs.app.R;
import com.lepu.app.widget.CustomTopBarNew;
import com.lepu.app.widget.CustomTopBarNew.OnTopbarNewLeftLayoutListener;

public class BmiResultActivity extends BaseFragmentActivity implements
		OnTopbarNewLeftLayoutListener {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		mNeedStatusBar = false;
		super.onCreate(savedInstanceState);
		setContentView(R.layout.index_bmi_result_activity);

		UtilityBase.setStatusBarRes(this, R.color.color_bmi, true);
		init();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	/**
	 * 添加页面动画，需要重写这个方法，
	 */
	@Override
	public void onBackPressed() {
		finish(true);
	}
	
	@Override
	public void onTopbarLeftLayoutSelected() {
		finish(true);
	}


	/**
	 * 初始化方法
	 */
	private void init() {
		// topbar
		CustomTopBarNew topbar = (CustomTopBarNew) findViewById(R.id.topbar);
		topbar.setTopbarTitle("BMI");
		topbar.setTopbarBackground(R.color.color_bmi);
		topbar.setonTopbarNewLeftLayoutListener(this);
		
		String result = "";
		Bundle data = getIntent().getExtras();
		if(data != null && data.size() > 0){
			result = data.getString("result");
		}
		
		double resultValue = Double.parseDouble(result);
		
		String tip1 = "";
		String tip2 = "";
		
		if(resultValue < 18.5)
		{
			tip1 = String.format("您过度苗条");
			tip2 = "应增加营养和锻炼";
		}else if(resultValue >= 18.5 && resultValue < 25){
			tip1 = String.format("您是健康体重");
			tip2 = "但已不苗条，小心哦";
		}else if(resultValue >= 25 && resultValue < 30){
			tip1 = String.format("您是超重了");
			tip2 = "应该立即减肥";
		}else{
			tip1 = String.format("您非常胖");
			tip2 = "肥胖将严重影响您的健康";
		}
		
		TextView tip1TextView = (TextView) findViewById(R.id.tip1TextView);
		TextView tip2TextView = (TextView) findViewById(R.id.tip2TextView);
		TextView resultTextView = (TextView) findViewById(R.id.resultTextView);
		
		tip1TextView.setText(tip1);
		tip2TextView.setText(tip2);
		resultTextView.setText(result);
	}
	
	public void viewClick(View view) {
		int rid = view.getId();
		switch (rid) {
		case R.id.testButton:

			finish(true);
			break;

		default:
			break;
		}
	}

}
